﻿using UnityEngine;
using System.Collections;

public class baleia_andando : MonoBehaviour {
	public int velx;
	Vector3 initialPosition;

	// Use this for initialization
	void Start () 
	{
		initialPosition = transform.position;
	}
	
	// Update is called once per frame
	void Update () 
	{	
		transform.position -= new Vector3(velx * Time.deltaTime, 0, 0);
		if (transform.position.x < -12) 
		{
			transform.position = new Vector3(initialPosition.x, Random.Range(1.1f, -4.6f), 0);
		}
	}
	void OnTriggerEnter2Dijij (Collider2D other)
	{
		if(other.gameObject.tag == "tiro")
		{
			Destroy(other.gameObject);
		}

	}
	
	void OnTriggerEnter2D(Collider2D other)
	{
		Destroy(other.gameObject);
	}
}
